package com.lld.crowdfunding.controller;

<<<<<<< HEAD
=======
import com.lld.crowdfunding.entity.QuanXian;
>>>>>>> 42dbb3a (20210806)
import com.lld.crowdfunding.service.UserService;
import com.lld.crowdfunding.util.Msg;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;


import javax.servlet.http.HttpSession;
<<<<<<< HEAD
=======
import java.util.List;
>>>>>>> 42dbb3a (20210806)


@Api(tags = "应用操作接口")
@Controller
public class AppController {

    @Autowired
    private UserService userService;


    @ApiOperation(value = "登录界面")
    @GetMapping(value = {"/login.html"})
    public String login() {
        return "login";
    }


    @ApiOperation(value = "用户管理页面")
    @GetMapping(value = {"/userManager.html"})
    public String mainPage(Model model, @RequestParam(required = false,defaultValue = "1") Integer pn,
                           @RequestParam(required = false,defaultValue = "5") Integer size) {
        Msg users = userService.getAllUser(null, null, pn, size);
        model.addAttribute("allUser",users.getExtend().get("pageInfo"));
        return "userManager";
    }

    @ApiOperation(value = "主界面")
    @GetMapping("/")
    public String main(HttpSession session) {
        Msg main = userService.main(session);
        return "redirect:/"+main.getExtend().get("mainPage").toString();
    }


    @ApiOperation(value = "订单管理界面")
    @GetMapping(value = {"/orderManager.html"})
    public String orderManager() {
        return "orderManager";
    }

<<<<<<< HEAD
=======
    @ApiOperation(value = "无权限界面")
    @GetMapping(value = {"/noAuthority"})
    public String noAuthority(HttpSession session,Model model) {
        List<QuanXian> quanxian = (List<QuanXian>) session.getAttribute("quanxian");
        if(quanxian==null || quanxian.size()==0) {
            model.addAttribute("backhome","login.html");
        } else {
            model.addAttribute("backhome","");
        }
        return "noAuthority";
    }

>>>>>>> 42dbb3a (20210806)

}
